/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trirparser;

import com.hp.hpl.jena.rdf.model.Model;
import java.io.*;
import java.util.ArrayList;
import org.apache.commons.net.ftp.FTPClient;
import trirparser.ontologija.VremeOntologija;

/**
 *
 * @author Irena
 */
public class ShraniFTP {
    
    private FTPClient ftpClient;
    private FileInputStream fis;

    public ShraniFTP() throws Exception {
        ftpClient = new FTPClient();
        ftpClient.connect("ftp.ribogojnica-pozeg.si");
        ftpClient.login("tose_care@ribogojnica-pozeg.si", "tosecare007");
        
    }
    
    
    
    public void Shrani(ArrayList<VremeOntologija> modeli) throws IOException{
        
      for(VremeOntologija m : modeli) {
          shraniModelNaFtp(m);
      }
      ftpClient.disconnect();
        
      
        
    }

    private void shraniModelNaFtp(VremeOntologija m) throws IOException {
        System.out.print(m.getImeDatoteke());
        BufferedWriter out = new BufferedWriter(new FileWriter(new File(m.getImeDatoteke() + ".rdf")));
        m.getModel().write(out, "RDF/XML");
        fis = new FileInputStream(m.getImeDatoteke() + ".rdf");
        ftpClient.storeFile(m.getImeDatoteke().replace(" ", ".") + ".rdf", fis);
        
    }
}
